package org.example.batchutils.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.extern.slf4j.Slf4j;
import org.example.batchutils.mapper.DeptMapper;
import org.example.batchutils.pojo.Dept;
import org.example.batchutils.pojo.Result;
import org.example.batchutils.service.DeptsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
@DS("#param.poolName")
public class DeptsServiceImpl implements DeptsService
{

    @Autowired
    private DeptMapper deptMapper;

    @Transactional
    @Override
    public Result getAllDepts(String poolName) {

        try {
            List<Dept> depts = deptMapper.getAllDepts();
            log.info("获取部门列表成功");
            return Result.success(depts);
        }
        catch (Exception e)
        {
            log.error("获取部门列表失败");
            return Result.error("获取部门列表失败");
        }

    }


}
